package com.hdax.dm.controller;

import com.hdax.dm.dto.PriceDto;
import com.hdax.dm.dto.ScheduleDto;
import com.hdax.dm.dto.TimePlanDao;
import com.hdax.dm.service.SchedulerSeatPriceService;
import com.hdax.dm.service.SchedulerService;
import com.hdax.dm.service.SeatService;
import com.hdax.dm.utils.response.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/scheduler")
public class SchedulerController {


    @Autowired
    private SchedulerService schedulerService;

    @Autowired
    private SchedulerSeatPriceService priceService;

    @Autowired
    private SeatService seatService;


    //  根据演出 ID 查询排期信息
    @PostMapping("desc/getTimePlan")
    public CommonResponse<List<TimePlanDao>> getTimePlan(@RequestBody Map<String,Integer> map){
        return schedulerService.getTimePlan(map.get("itemId"));
    }

    //  根据 排期ID查找票价信息
    @PostMapping("desc/getPrice")
    public CommonResponse<List<PriceDto>> getPrice(@RequestBody Map<String,Integer> map){
        return priceService.getPrice(map.get("scheduleId"));
    }

    //  获取座位信息api_chooseSeat.getSchedule
    @PostMapping("choose/seat/getSeatList")
    public CommonResponse<Map<String,List<String>>> getSeatList(@RequestBody Map<String,Long> map){
        return seatService.getSeatList(map.get("cinemaId"),map.get("scheduleId"));
    }

    //  获取座位状态等信息
    @PostMapping("choose/seat/getSchedule")
    public CommonResponse<ScheduleDto> getSchedule(@RequestBody Map<String,Long> map){
        return schedulerService.getSchedule(map.get("cinemaId"),map.get("scheduleId"));
    }
}
